home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 7: Programming / CDAT7.iso / demos / VisualAge for Java 2.0 Entry / setup / data1.cab / ide-e / IDE / cache / 1KFKIGF (.txt) < prev    next >
Encoding:
Java Class File  |  1998-09-16  |  2.3 KB  |  57 lines

  1. package com.sun.java.swing.plaf.metal;
  2.  
  3. import com.sun.java.swing.BoundedRangeModel;
  4. import com.sun.java.swing.JComponent;
  5. import com.sun.java.swing.JProgressBar;
  6. import com.sun.java.swing.plaf.ComponentUI;
  7. import com.sun.java.swing.plaf.basic.BasicProgressBarUI;
  8. import java.awt.Component;
  9. import java.awt.Dimension;
  10. import java.awt.Graphics;
  11. import java.awt.Insets;
  12. import java.awt.Rectangle;
  13.  
  14. public class MetalProgressBarUI extends BasicProgressBarUI {
  15.    public static ComponentUI createUI(JComponent c) {
  16.       return new MetalProgressBarUI();
  17.    }
  18.  
  19.    public void paint(Graphics g, JComponent c) {
  20.       super.paint(g, c);
  21.       JProgressBar progressBar = (JProgressBar)c;
  22.       BoundedRangeModel model = progressBar.getModel();
  23.       Dimension size = ((Component)progressBar).getSize();
  24.       Insets i = ((JComponent)progressBar).getInsets();
  25.       Rectangle barRect = new Rectangle(size);
  26.       barRect.x += i.left;
  27.       barRect.y += i.top;
  28.       barRect.width -= i.right + barRect.x;
  29.       barRect.height -= i.bottom + barRect.y;
  30.       int amountFull = ((BasicProgressBarUI)this).getAmountFull(c);
  31.       if (progressBar.getOrientation() == 0) {
  32.          g.setColor(MetalLookAndFeel.getControlShadow());
  33.          g.drawLine(barRect.x, barRect.y, barRect.width, barRect.y);
  34.          if (model.getValue() == model.getMinimum()) {
  35.             g.setColor(MetalLookAndFeel.getControlShadow());
  36.          } else {
  37.             g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
  38.          }
  39.  
  40.          g.drawLine(barRect.x, barRect.y, barRect.x, barRect.height);
  41.          g.drawLine(barRect.x, barRect.y, amountFull, barRect.y);
  42.       } else {
  43.          g.setColor(MetalLookAndFeel.getControlShadow());
  44.          g.drawLine(barRect.x, barRect.y, barRect.x, barRect.height);
  45.          if (model.getValue() == model.getMinimum()) {
  46.             g.setColor(MetalLookAndFeel.getControlShadow());
  47.          } else {
  48.             g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
  49.          }
  50.  
  51.          g.drawLine(barRect.x, barRect.height, barRect.width, barRect.height);
  52.          g.drawLine(barRect.x, barRect.height, barRect.x, barRect.height - amountFull);
  53.       }
  54.  
  55.    }
  56. }
  57.